import requestProxy from '@/utils/request';
import md5 from 'js-md5';
const { request } = requestProxy;

export function login(username, password) {
  // eslint-disable-next-line no-undef
  password = md5(password);
  return request({
    url: '/admin/login',
    method: 'post',
    data: {
      username,
      password
    }
  });
}
// 钉钉登录
export function ddLogin(data) {
  return request({
    url: '/dingTalk/login',
    method: 'post',
    data
  });
}

// 飞书登录
export function feishuLogin(data) {
  return request({
    url: '/feishu/login',
    method: 'post',
    data
  });
}
// 获取用户详情
export function getInfo(id) {
  return request({
    url: `/admin/user/info/${id}`,
    method: 'get'
  });
}
// 获取用户权限
export function getUserAuth() {
  return request({
    url: '/admin/user/auth',
    method: 'get'
  });
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  });
}

// 发送验证码
export function sendCode(params) {
  return request({
    url: '/admin/send/code',
    method: 'get',
    params
  });
}

// 重置密码
export function resetPwd(params) {
  return request({
    url: '/admin/reset/pwd',
    method: 'put',
    params
  });
}
export function sendDingTalk(data) {
  return request({
    url: '/dingTalk/send',
    method: 'post',
    data
  });
}
export function sendFeishuTalk(data) {
  return request({
    url: '/feishu/send',
    method: 'post',
    data
  });
}
export function getDataUpdateTime(params) {
  return request({
    url: 'admin/data/dataUpdateTime',
    method: 'get',
    params
  });
}

export function getLoginPageConfig() {
  return request({
    url: 'admin/login/getLoginPageConfig',
    method: 'get'
  });
}

export function editLoginPageConfig(data) {
  return request({
    url: 'admin/login/editLoginPageConfig',
    method: 'post',
    data
  });
}
